/**
 * StarInfoFrameColonized.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UIButton;
import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.backdrop.SolidBackdrop;
import com.ardor3d.extension.ui.event.ActionEvent;
import com.ardor3d.extension.ui.event.ActionListener;
import com.ardor3d.extension.ui.layout.AnchorLayout;
import com.ardor3d.extension.ui.layout.AnchorLayoutData;
import com.ardor3d.extension.ui.util.Alignment;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.image.Texture;
import com.ardor3d.util.TextureManager;
import com.roslan.games.moo3d.GameData;
import com.roslan.games.moo3d.GameData.Actions;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * Comments go here.
 * 
 * @author Roslan Amir
 * @version 1.0 - Mar 2, 2011
 */
public class StarInfoFrameColonized extends StarInfoFrameBase {

	/**
	 * 
	 */
	private static final String IMAGE_COLONIZED = "images/sample-system.jpg";

	/**
	 * The label for the description text.
	 */
	private final UILabel descValueLabel;

	/**
	 * Default no-arg constructor.
	 */
	public StarInfoFrameColonized() {
		super("New Star Colonized", new SolidBackdrop(GameData.COLOR_CHOCOLATE));

		/*
		 * Image Label
		 */
		final Texture tex = TextureManager.load(IMAGE_COLONIZED, Texture.MinificationFilter.Trilinear, false);
		final SubTex image = new SubTex(tex);

		final UIPanel panel = new UIPanel();
		panel.setLayout(new AnchorLayout());
		infoPanel.add(panel);

		final UILabel imageLabel = new UILabel("", image);
		imageLabel.setGap(0);
		imageLabel.setMargin(HudManager.MARGINS_ZERO);
		imageLabel.setPadding(HudManager.PADDING_ZERO);
		imageLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 0, -4));
		panel.add(imageLabel);

		descValueLabel = new UILabel("");
		descValueLabel.setStyledText(true);
		descValueLabel.setAlignment(Alignment.MIDDLE);
		descValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 0, -4));
		panel.add(descValueLabel);

		/*
		 * Close button
		 */
//		final UIButton closeButton = new UIButton("[b]Close[/b]");
		final UIButton closeButton = new UIButton("Close");
		closeButton.setStyledText(true);
		descValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 0, -90));
		closeButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				gameData.action = Actions.HIDE_COLONIZED_INFO;
			}
		});
		panel.add(closeButton);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roslan.games.moo3d.ui.StarInfoFrameBase#update(com.roslan.games.moo3d.spatial.StarNode)
	 */
	@Override
	public void update(StarNode starNode) {
//		descValueLabel.setText("[b][c=#fff]On stardate 2400.3, the Humans form a new colony[/c][/b]");
		descValueLabel.setText("[c=#fff]On stardate 2400.3, the Humans form a new colony[/c]");
		updateAndpack();
	}

}
